package com.gitee.xhs.broadcastState;

import cn.hutool.core.date.DateUtil;
import com.gitee.xhs.util.StringTemplateUtil;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * @author BigHead
 * @date 2022/7/4 14:55
 * @description BroadcastStateDao
 */
public class BroadcastStateDao {

    private static final String BROADCAST_DESCRIBE = "广播信息${MESSAGE_KEY}, 展示信息";
    private static final String MESSAGE_KEY = "MESSAGE_KEY";

    private final long accountId;
    private String showMessage;

    private long dataTime;

    public BroadcastStateDao(long accountId) {
        this.accountId = accountId;
        makeShowMessage();
    }

    public BroadcastStateDao(long accountId, long dataTime) {
        this.accountId = accountId;
        this.dataTime = dataTime;
        makeShowMessage();
    }

    private void makeShowMessage() {
        Map<String, String> templateMap = new HashMap<>(1);
        templateMap.put(MESSAGE_KEY, accountId + "");
        this.showMessage = StringTemplateUtil.render(
                BROADCAST_DESCRIBE,
                templateMap
        );
    }


    public long getAccountId() {
        return accountId;
    }

    public long getDataTime() {
        return dataTime;
    }

    public void setDataTime(long dataTime) {
        this.dataTime = dataTime;
    }

    public String getShowMessage() {
        return showMessage;
    }

    @Override
    public String toString() {
        return "BroadcastStateDao{" +
                "accountId=" + accountId +
                ", showMessage='" + showMessage + '\'' +
                ", dataTime=" + dataTime +
                ", dateTimeString='" + DateUtil.formatDateTime(new Date(dataTime)) + "'" +
                '}';
    }
}
